﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using log4net;
using System.IO;

namespace KLY.Tools.Helper
{
    public static class LogHelper
    {
        public static readonly ILog loger = log4net.LogManager.GetLogger("loger");

        public static void SetLogConfig()
        {
            log4net.Config.XmlConfigurator.Configure();
        }

        public static void SetLogConfig(FileInfo configFile)
        {
            log4net.Config.XmlConfigurator.Configure(configFile);
        }

        public static void WriteLogInfo(string error)
        {
            if (loger.IsInfoEnabled)
            {
                loger.Info(error);
            }
        }

        public static void WriteLogInfo(string error, Exception ex)
        {
            if (loger.IsInfoEnabled)
            {
                loger.Info(error, ex);
            }
        }

        public static void WriteLogError(string error,Exception ex)
        {
            if (loger.IsErrorEnabled)
            {
                loger.Error(error, ex);
            }
        }

        public static void WriteLogError(string error)
        {
            if (loger.IsErrorEnabled)
            {
                loger.Error(error);
            }
        }

        public static void WriteLogWarn(string error)
        {
            if (loger.IsWarnEnabled)
            {
                loger.Warn(error);
            }
        }

        public static void WriteLogWarn(string error,Exception ex)
        {
            if (loger.IsWarnEnabled)
            {
                loger.Warn(error,ex);
            }
        }

        public static void WriteLogFatal(string error)
        {
            if (loger.IsFatalEnabled)
            {
                loger.Fatal(error);
            }
        }

        public static void WriteLogFatal(string error, Exception ex)
        {
            if (loger.IsFatalEnabled)
            {
                loger.Fatal(error,ex);
            }
        }

        public static void WriteLogDebug(string error)
        {
            if (loger.IsDebugEnabled)
            {
                loger.Debug(error);
            }
        }

        public static void WriteLogDebug(string error, Exception ex)
        {
            if (loger.IsDebugEnabled)
            {
                loger.Debug(error, ex);
            }
        }
    }
}
